#!/usr/bin/env python
# encoding: utf-8
'''
@author: 王震
@license: 四川凡狼科技有限公司
@contact: 2668985108@qq.com
@file: interview.py
@time: 2022/1/13 9:16 下午
@desc:
'''

from flask import Blueprint, request
from app.business.interview.interview import *
from app.public.sqlMethods import auto

interview = Blueprint(name='interview', import_name='__name__', url_prefix='/api')


@interview.route('/add/interview/type', methods=['POST'])
@auto.login_required
def add_interview_type() -> dict:
    """
    创建面试题类型
    :return: dict
    """
    data = request.json
    return add_interview(name=data['name'])


@interview.route('/get/interview', methods=['GET'])
@auto.login_required
def get_interview() -> list:
    """
    管理系统获取面试题类型列表
    :return: list
    """
    page_number = request.args.get('pageNumber', 1)
    page_size = request.args.get('pageSize', 10)
    return get_system_interview(page_number=page_number, page_size=page_size)


@interview.route('/get/interview/list', methods=['GET'])
def interview_list() -> list:
    """
    获取客户端面试题类型列表
    :return: list
    """
    page_number = request.args.get('pageNumber', 1)
    page_size = request.args.get('pageSize', 10)
    return get_interview_list(page_number=page_number, page_size=page_size)


@interview.route('/edit/interview', methods=['PUT'])
@auto.login_required
def _edit_interview():
    """
    编辑面试题
    :return:
    """
    data = request.json
    return edit_interview(data=data)


@interview.route('del/interview', methods=['DELETE'])
@auto.login_required
def _del_interview():
    """
    删除面试题类型
    :return:
    """
    data = request.json
    id = data['id']
    return del_interview(id=id)


@interview.route('/add/interview/questions', methods=['POST'])
# @auto.login_required
def _add_interview_questions():
    """
    创建面试题
    :return:
    """
    data = request.json
    return add_interview_questions(data=data)


@interview.route('/get/interview/questions', methods=['GET'])
def _get_interview_questions():
    """
    客户端获取面试题列表
    :return:
    """
    page_number = request.args.get('pageNumber', 2)
    page_size = request.args.get('page_size', 10)
    return get_interview_questions(page_number=page_number, page_size=page_size)
